package leetcode.code344.ReverseString;

public class Solution1 implements IReverseString {

	@Override
	public void reverseString(char[] s) {
		if (s == null || s.length == 1)
			return;
		for (int i = 0, j = s.length - 1; i <= j; i++, j--) {
			char temp = s[i];
			s[i] = s[j];
			s[j] = temp;
		}
	}

	@Override
	public void debug(char[] s, IReverseString i) {
		i.reverseString(s);
		for (char c : s) {
			System.out.print(c + ",");
		}
		System.out.println("");
	}

	@Override
	public void debug1(IReverseString i) {
//		���룺["h","e","l","l","o"]
//		�����["o","l","l","e","h"]
		char[] s = new char[] { 'h', 'e', 'l', 'l', 'o' };
		System.out.println("o,l,l,e,h");
		this.debug(s, i);
	}

	@Override
	public void debug2(IReverseString i) {
//		���룺["H","a","n","n","a","h"]
//		�����["h","a","n","n","a","H"]
		char[] s = "Hannah".toCharArray();
		System.out.println("h,a,n,n,a,H");
		this.debug(s, i);
	}

	public static void main(String[] args) {
		Solution1 so = new Solution1();
		so.debug1(so);
		System.out.println("===");
		so.debug2(so);
	}

}
